package org.soderiakelvy.controller.test;

import java.util.Map;

import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;  
import javax.faces.event.ActionListener;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;  
import javax.faces.application.FacesMessage;

import org.soderiakelvy.controller.util.Constante;

@ManagedBean
public class MessagesController implements ActionListener{  
  
    public void addInfo() {  
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Sample info message", "PrimeFaces rocks!"));  
    }  
  
    public void addWarn(ActionEvent actionEvent) {  
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,"Sample warn message", "Watch out for PrimeFaces!"));  
    }  
  
    public void addError(ActionEvent actionEvent) {  
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Sample error message", "PrimeFaces makes no mistakes"));  
    }  
  
    public void addFatal(ActionEvent actionEvent) {  
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL,"Sample fatal message", "Fatal Error in System"));  
    }
    
    
    public String updateAguaDeRed(){
    	return "sujetoAguaDeRed.xhtml";
    }
    
    public String assignAguaDeRed(){
    	String result = Constante.SUJETO_EMPRESA_CREATE;
		FacesContext fc = FacesContext.getCurrentInstance();
		Map<String,Object> sessionParams = fc.getExternalContext().getSessionMap();
		sessionParams.put("tipoCrud", result);
    	return "sujetoAguaDeRed.xhtml";
    }
    
    public void actionListener(ActionEvent actionEvent){
        System.out.println("actionListener of the button is called");
    }
    public String action(){
        System.out.println("action of the button is called");
        return null;
    }
 
    public void setProperty(String property) {
        System.out.println("f:setPropertyActionListener for property is called "+property);
    }
 
    public void setProperty2(String property2) {
        System.out.println("f:setPropertyActionListener for property2 is called"+ property2);
    }
     
    @Override
    public void processAction(ActionEvent ae) throws AbortProcessingException {
        System.out.println("f:actionlistener is called");
    }
}  
